package com.ellison.springdemo.springbase.mvc.controller;

import org.springframework.stereotype.Component;
import org.springframework.web.HttpRequestHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 通过 implements HttpRequestHandler  来做controller
 * 这种方式要 通过 SimpleUrlHandlerMapping 去手动添加 映射关系
 *
 * @author Ellison_Pei
 * @date 2022/3/9 19:32
 * @since 1.0
 **/
@Component
public class AreaController implements HttpRequestHandler {
    @Override
    public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("==============AreaController");
        PrintWriter writer = response.getWriter();
        writer.println("<h1>===============AreaController -> handleRequest()=============</h1>");
        writer.flush();
        writer.close();
    }
}
